Напишите функцию sum_range(start, end), которая суммирует все целые числа от значения «start» до величины «end» включительно. Если пользователь задаст первое число большее чем второе, просто поменяйте их местами.
При решении удобно воспользоваться встроенными функциями range() и sum().
Решение:
def sum_range(start, end): if start > end: end, start = start, end return sum(range(start, end + 1))
# Тесты print(sum_range(2, 12)) print(sum_range(-4, 4)) print(sum_range(3, 2)) Результат выполнения: 77 0 5 Свой вариант решения в комментарии 💬
Напишите функцию sum_range(start, end), которая суммирует все целые числа от значения «start» до величины «end» включительно. Если пользователь задаст первое число большее чем второе, просто поменяйте их местами.
При решении удобно воспользоваться встроенными функциями range() и sum().
Решение:
def sum_range(start, end): if start > end: end, start = start, end return sum(range(start, end + 1))
# Тесты print(sum_range(2, 12)) print(sum_range(-4, 4)) print(sum_range(3, 2)) Результат выполнения: 77 0 5 Свой вариант решения в комментарии 💬
#задачи
BY Python Turbo. Уютное сообщество Python разработчиков.
In many cases, the content resembled that of the marketplaces found on the dark web, a group of hidden websites that are popular among hackers and accessed using specific anonymising software.“We have recently been witnessing a 100 per cent-plus rise in Telegram usage by cybercriminals,” said Tal Samra, cyber threat analyst at Cyberint.The rise in nefarious activity comes as users flocked to the encrypted chat app earlier this year after changes to the privacy policy of Facebook-owned rival WhatsApp prompted many to seek out alternatives.
Tata Power whose core business is to generate, transmit and distribute electricity has made no money to investors in the last one decade. That is a big blunder considering it is one of the largest power generation companies in the country. One of the reasons is the company's huge debt levels which stood at ₹43,559 crore at the end of March 2021 compared to the company’s market capitalisation of ₹44,447 crore.
Python Turbo Уютное сообщество Python разработчиков from ua